import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sainbainu/common/values/colors.dart';

import 'index.dart';

class NoticePage extends GetView<NoticeController> {
  const NoticePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<NoticeController>(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: Text("消息通知".tr)),
          body: EasyRefresh.builder(
            controller: _.state.refreshController,
            onLoad: _.onRichBottom,
            childBuilder: (context, physics) {
              return _buildBody(physics);
            },
          ),
        );
      },
    );
  }

  /// 列表
  Widget _buildBody(ScrollPhysics physics) {
    return ListView.separated(
      physics: physics,
      itemCount: 5,
      padding: const EdgeInsets.all(0),
      separatorBuilder: (context, index) {
        return const SizedBox(height: 10);
      },
      itemBuilder: (context, index) {
        return _buildItemCard();
      },
    );
  }

  /// 列表每一项
  Widget _buildItemCard() {
    return Container(
      color: Colors.white,
      padding: const EdgeInsets.all(15),
      child: const Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text(
            '实名认证',
            style: TextStyle(
              fontSize: 15,
              fontWeight: FontWeight.w600,
              color: AppColors.active,
            ),
          ),
          SizedBox(height: 4),
          Text(
            'sainbainu 恭喜您，实名认证成功！请用您的善言温暖每一个人。',
            style: TextStyle(
              fontSize: 14,
              color: AppColors.active2,
            ),
          ),
          SizedBox(height: 6),
          Text(
            '2024-06-18',
            style: TextStyle(color: AppColors.unactive3, fontSize: 12),
          ),
        ],
      ),
    );
  }
}
